#!/bin/sh

##########################################################
# refresh device table and nodes
##########################################################

ROOTDEVICE=/dev/mtdblock4
TMPROOTFSD="/tmp/rootfs"

# create some folders in devfs
ndirs="pty tts cua misc usb block disk serial"
for dir in $ndirs ; do
    mkdir -p "/dev/$dir" 2> /dev/null
done

# init dev particion
if [ -d $TMPROOTFSD ]; then
    cp -rpf $TMPROOTFSD/dev/* /dev
fi

# make symlink for kcore
if [ -f /proc/kcore ]; then
    ln -sf /proc/kcore /dev/core
fi

# make symlink for rootdev
if [ -f $ROOTDEVICE ]; then
    ln -sf $ROOTDEVICE /dev/root
fi

# hw independed
mknod /dev/tts/0	c	4	64
mknod /dev/tts/1	c	4	65
mknod /dev/cua/0	c	5	64
mknod /dev/misc/rtc	c	10	135

for i in `seq 0 15`; do
    mknod /dev/pty/m$i c 2 $i
done

for i in `seq 0 3`; do
    mknod /dev/aci$i c 254 $i
done
for i in `seq 0 1`; do
    mknod /dev/gpio$i c 252 $i
done

# ralink depended
mknod /dev/swnat0	c	210	0
mknod /dev/hwnat0	c	215	0
mknod /dev/i2cM0	c	218	0
mknod /dev/acl0		c	230	0
mknod /dev/PCM		c	233	0
mknod /dev/pcm0		c	233	0
mknod /dev/I2S		c	234	0
mknod /dev/i2s0		c	234	0
mknod /dev/cls0		c	235	0
mknod /dev/ac0		c	240	0
mknod /dev/mrt0		c	250	0
mknod /dev/nvram	c	251	0
mknod /dev/gpio		c	252	0
mknod /dev/rdm0		c	254	0

# for realtek external gigaphy
mknod /dev/rtl8367m	c	206	0

# autocreate/refrash some dev nodes
mdev -s
